package com.hzlj.position.config.common.enums;

import com.fz.common.base.exception.PubError;
import com.fz.common.base.exception.PubException;
import lombok.Getter;

/**
 * @author fanzhuo
 */

@Getter
public enum ReportType {
    INITIATIVE("0", "人脸签到"),
    AUTO("1", "自动点验"),
    ARTIFICIAL("2", "人工点验"),
    VIDEO("3", "视频点验"),
    CORRECT("4", "位置纠偏"),
    /**
     * 越界、关机、拆卸
     */
    TRACK_CHECK("5", "位置确认"),
    INDEPENDENT("6", "主动上报"),
    /**
     * 运营商位置异常
     */
    POSITION_CHECK("7", "位置确认"),
    /**
     * 运营商定位
     */
    OPERATOR_TIMED("20", "运营商定位"),
    /**
     * 腕带定位
     */
    WD("21", "腕带定位"),
    /**
     * App定时上报
     */
    APP_TIMED("22", "APP定时上报"),
    ;

    private String code;
    private String text;

    ReportType(String code, String text) {
        this.code = code;
        this.text = text;
    }

    public static ReportType of(String value) {
        for (ReportType reportType : values()) {
            if (reportType.getCode().equals(value)) {
                return reportType;
            }
        }
        throw new PubException(PubError.PARAM_EMPTY_ERROR);
    }

    public static ReportType ofName(String name) {
        for (ReportType reportType : values()) {
            if (reportType.name().equalsIgnoreCase(name)) {
                return reportType;
            }
        }
        throw new PubException(PubError.PARAM_EMPTY_ERROR);
    }
}
